package com.example.hosinject.util;

import com.example.hosinject.ResourceTable;
import ohos.agp.components.DirectionalLayout;
import ohos.agp.components.LayoutScatter;
import ohos.agp.components.Text;
import ohos.agp.utils.LayoutAlignment;
import ohos.agp.window.dialog.ToastDialog;
import ohos.app.Context;

public class ToastUtils {

    public static ToastDialog createToastDialog(Context context, String content, int alignment) {
        DirectionalLayout rootLayout = (DirectionalLayout) LayoutScatter.getInstance(context).parse(ResourceTable.Layout_toast_layout, null, false);
        Text text = (Text) rootLayout.findComponentById(ResourceTable.Id_msg_toast);
        text.setText(content);
        return new ToastDialog(context).setComponent(rootLayout).setAlignment(alignment);
    }
}
